<script setup lang="ts">
import Top from './top/index.vue'
import Tourist from './tourist/index.vue'
import Sex from './sex/index.vue'
import Age from './age/index.vue'

import Map from './map/index.vue'
import Center2 from './center2/index.vue'

import Rank from './rank/index.vue'
import Year from './year/index.vue'
import Counter from './counter/index.vue'
const screen = ref()
// 计算大屏缩放比例
const getScale = (w = 1920, h = 1080) => {
  const ww = window.innerWidth / w
  const wh = window.innerHeight / h
  return ww < wh ? ww : wh
}
onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
})
// 监听屏幕大小变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
}
</script>

<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top"><Top /></div>
      <div class="bottom">
        <div class="left">
          <Tourist class="tourist" />
          <Sex class="sex" />
          <Age class="age" />
        </div>
        <div class="center">
          <Map class="map" />
          <Center2 class="center2" />
        </div>
        <div class="right">
          <Rank class="tourist" />
          <Year class="sex" />
          <Counter class="age" />
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  background-size: cover;
  .screen {
    width: 1920px;
    height: 1080px;
    position: fixed;
    left: 50%;
    top: 50%;
    transform-origin: left top;
  }
  .top {
    width: 100%;
    height: 40px;
  }
  .bottom {
    width: 100%;
    display: flex;
    .left {
      flex: 1;
      // height: 1040px;
      display: flex;
      flex-direction: column;
      .tourist {
        flex: 1.5;
      }
      .sex {
        flex: 1;
      }
      .age {
        flex: 1;
      }
    }
    .center {
      flex: 3;
      margin: 84px, 10px, 10px, 10px;

      // height: 1006px;
      display: flex;
      flex-direction: column;
      .map {
        flex: 3;
      }
      .center2 {
        flex: 1;
      }
    }
    .right {
      flex: 1;
      height: 1040px;
      display: flex;
      flex-direction: column;
      .tourist {
        flex: 1.5;
      }
      .sex {
        flex: 1;
      }
      .age {
        flex: 1;
      }
    }
  }
}
</style>
